package com.ruoyi.baoming.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.baoming.domain.ExamMajor;
import com.ruoyi.baoming.service.IExamMajorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 报考专业信息Controller
 * 
 * @author xiaosong
 * @date 2024-11-20
 */
@Api(tags = "考试管理-专业管理")
@RestController
@RequestMapping("/baoming/examMajor")
public class ExamMajorController extends BaseController
{
    @Autowired
    private IExamMajorService examMajorService;

    /**
     * 查询报考专业信息列表
     */
    @PreAuthorize("@ss.hasPermi('baoming:examMajor:list')")
    @GetMapping("/list")
        @ApiOperation("考试专业管理 - 分页查询列表")
    public TableDataInfo list(ExamMajor examMajor)
    {
        startPage();
        List<ExamMajor> list = examMajorService.selectExamMajorList(examMajor);
        return getDataTable(list);
    }

    /**
     * 导出报考专业信息列表
     */
    @PreAuthorize("@ss.hasPermi('baoming:examMajor:export')")
    @Log(title = "报考专业信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("考试专业管理 - 导出数据")
    public void export(HttpServletResponse response, ExamMajor examMajor)
    {
        List<ExamMajor> list = examMajorService.selectExamMajorList(examMajor);
        ExcelUtil<ExamMajor> util = new ExcelUtil<ExamMajor>(ExamMajor.class);
        util.exportExcel(response, list, "报考专业信息数据");
    }

    /**
     * 获取报考专业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:examMajor:query')")
    @GetMapping(value = "/{id}")
        @ApiOperation("考试专业管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(examMajorService.selectExamMajorById(id));
    }

    /**
     * 新增报考专业信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:examMajor:add')")
    @Log(title = "报考专业信息", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("考试专业管理 - 新增数据")
    public AjaxResult add(@RequestBody ExamMajor examMajor)
    {
        return toAjax(examMajorService.insertExamMajor(examMajor));
    }

    /**
     * 修改报考专业信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:examMajor:edit')")
    @Log(title = "报考专业信息", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("考试专业管理 - 修改数据")
    public AjaxResult edit(@RequestBody ExamMajor examMajor)
    {
        return toAjax(examMajorService.updateExamMajor(examMajor));
    }

    /**
     * 删除报考专业信息
     */
    @PreAuthorize("@ss.hasPermi('baoming:examMajor:remove')")
    @Log(title = "报考专业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
        @ApiOperation("考试专业管理 - 删除数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(examMajorService.deleteExamMajorByIds(ids));
    }
}
